package com.os.serviceimpl;

import java.util.ArrayList;
import java.util.List;

import com.os.dao.FoodDaoX;
import com.os.daoimpl.FoodDaoImpX;
import com.os.model.FoodX;
import com.os.service.ReferFoodServiceX;

import net.sf.json.JSONObject;
import net.sf.json.processors.JsonBeanProcessor;

public class ReferFoodServiceImpX implements ReferFoodServiceX{
	FoodDaoX fao = new FoodDaoImpX();
	@Override
	public List referFoodService(int start, int pageSize) {
		// TODO Auto-generated method stub
		return fao.selectFood(start, pageSize);
	}

	@Override
	public int getFoodCount() {
		// TODO Auto-generated method stub
		return fao.getFoodCount();
	}

	@Override
	public List showFoodByftype(String ftype, int start, int pageSize) {
		// TODO Auto-generated method stub
		return fao.selectFoodByFtype(ftype, start, pageSize);
	}

	@Override
	public int contfoodbytype(String ftype) {
		// TODO Auto-generated method stub
		return fao.getFoodCountBytype(ftype);
	}

	

	@Override
	public int contLike(String like) {
		// TODO Auto-generated method stub
		return fao.selectLikeCont(like);
	}

	
	@Override
	public List likeShow(String like, int start, int pageSize) {
		// TODO Auto-generated method stub
		return fao.selectLike(like, start, pageSize);
	}

	@Override
	public List<FoodX> selectFnameAndfhasmaByIds(String[] fid) {
		List<FoodX> li = new  ArrayList<FoodX>();
		for (int i = 0; i < fid.length; i++) {
			FoodX f = fao.selectFnameAndfhasmaById(Integer.parseInt(fid[i]));
			if(f!=null){
			li.add(f);
			}
		}
		/*JSONObject js = new JSONObject();
		js.put("1",li);
		System.out.println(js);*/
		return li;
	}

}
